<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的账户</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    html,
    body {
        height: 100%;
        background-color: #f0f0f0;
    }
    
    header {
        position: relative;
        width: 100%;
        height: 150px;
        background-color: #e3007f;
    }
    
    header .back {
        position: absolute;
        bottom: 100px;
        left: 0;
        width: 80px;
        height: 50px;
        z-index: 2;
    }
    
    header .back img {
        margin-top: 16px;
        margin-left: 12px;
        width: 11px;
        height: 18px;
    }
    
    header .right {
        position: absolute;
        right: 12px;
        bottom: 100px;
        width: 50px;
        height: 50px;
    }
    
    header .right .accounthelp {
        position: absolute;
        top: 13px;
        right: 0;
        width: 24px;
        height: 24px;
        background-image: url(../image/accounthelp.png);
        background-size: auto 24px;
        background-position: center center;
    }
    
    header .top {
        position: relative;
        top: 50px;
        width: 100%;
        height: 40px;
        color: #fff;
        line-height: 40px;
        font-size: 14px;
        text-align: center;
    }
    
    header .bottom {
        position: relative;
        top: 50px;
        width: 100%;
        height: 40px;
        color: #fff;
        line-height: 40px;
        font-size: 24px;
        font-weight: bolder;
        text-align: center;
    }
    
    nav {
        position: relative;
        box-sizing: border-box;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-box-orient: horizontal;
        -webkit-flex-flow: row;
        flex-flow: row;
        width: 100%;
        height: 40px;
        padding-left: 16px;
        padding-right: 16px;
        background-color: #f0f0f0;
    }
    
    nav .menu {
        -webkit-box-flex: 1;
        -webkit-flex: 1;
        flex: 1;
        box-sizing: border-box;
        padding-left: 30px;
        height: 40px;
        color: #444;
        font-size: 14px;
        text-align: center;
        line-height: 40px;
        border-bottom: 2px solid #f0f0f0;
        background-repeat: no-repeat;
        background-size: auto 14px;
        background-position: 16px 13px;
    }
    
    nav .menu:nth-child(1) {
        background-image: url(../image/account_0.png);
    }
    
    nav .menu:nth-child(1).selected {
        background-image: url(../image/account_0_select.png);
    }
    
    nav .menu:nth-child(2) {
        background-image: url(../image/account_1.png);
    }
    
    nav .menu:nth-child(2).selected {
        background-image: url(../image/account_1_select.png);
    }
    
    nav .menu:nth-child(3) {
        background-image: url(../image/account_2.png);
    }
    
    nav .menu:nth-child(3).selected {
        background-image: url(../image/account_2_select.png);
    }
    
    nav .menu:nth-child(4) {
        background-image: url(../image/account_3.png);
    }
    
    nav .menu:nth-child(4).selected {
        background-image: url(../image/account_3_select.png);
    }
    
    nav .selected {
        font-weight: bolder;
        color: #e3007f;
        border-bottom: 2px solid #e3007f;
    }
    </style>
</head>

<body>
    <header id="header">
        <div class="back" tapmode onclick="api.closeWin();">
            <img src="../image/back.png">
        </div>
        <div class="right" tapmode onclick="fnOpenBalanceHelpWin();">
            <div class="accounthelp"></div>
        </div>
        <div class="top">优鲜余额</div>
        <div class="bottom">￥0</div>
    </header>
    <nav id="nav">
        <div class="menu selected" tapmode onclick="fnSetFrameGroupIndex(0)">充值有礼</div>
        <div class="menu" tapmode onclick="fnSetFrameGroupIndex(1)">卡卷兑换</div>
        <div class="menu" tapmode onclick="fnSetFrameGroupIndex(2)">账单记录</div>
    </nav>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function() {

    var header = $api.byId('header');
    $api.fixStatusBar(header);
    var nav = $api.byId('nav');

    var headerH = $api.offset(header).h;
    var navH = $api.offset(nav).h;

    menus = $api.domAll(nav, '.menu');

    // 打开FrameGroup Layout
    var frames = [{
        name: 'recharge_frame',
        url: './recharge_frame.html'
    }, {
        name: 'exchange_frame',
        url: './exchange_frame.html'
    }, {
        name: 'billhistory_frame',
        url: './billhistory_frame.html'
    }, ];
    api.openFrameGroup({
        name: 'accountFrameGroup',
        scrollEnabled: true,
        rect: {
            x: 0,
            y: headerH + navH,
            w: 'auto',
            h: 'auto'
        },
        index: 0,
        frames: frames,
        preload: frames.length
    }, function(ret, err) {
        if (ret) {
            fnSetNavMenuSelected(ret.index);
        } else {
            alert(JSON.stringify(err));
        }
    });
};

var menus;

function fnSetFrameGroupIndex(index_) {
    fnSetNavMenuSelected(index_);
    api.setFrameGroupIndex({
        name: 'accountFrameGroup',
        index: index_,
        scroll: true
    });
}

function fnSetNavMenuSelected(index_) {
    for (var i = 0; i < menus.length; i++) {
        if (index_ == i) {
            $api.addCls(menus[i], 'selected');
        } else {
            $api.removeCls(menus[i], 'selected');
        }
    }
}

function fnOpenBalanceHelpWin() {
    api.openWin({
        name: 'balancehelp',
        url: './balancehelp.html'
    });
}
</script>

</html>
